<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.util.List" %>
<%@ page import="admin.board.boardModel" %>
<jsp:useBean id="dao" scope="page" class="admin.board.boardDao" />
<%
String menu = "4";
	/*
	페이징 관련 
	*/
	String pageName = "faq_list.jsp";
	String viewName = "faq_view.jsp";
	int     giSelectPage  	= Integer.parseInt(request.getParameter("txtSelectPage") == null ? "0" :request.getParameter("txtSelectPage"));			//현재 선택된 페이지 저장
	int     giSelectBlock 	= Integer.parseInt(request.getParameter("txtSelectBlock") == null ? "0" :request.getParameter("txtSelectBlock"));			//현재 선택된 블락페이지 저장
	String searchGubn  = request.getParameter("searchGubn") == null ? "" : request.getParameter("searchGubn");
	String searchValue = request.getParameter("searchValue") == null ? "" : request.getParameter("searchValue");
	String searchBoard = "faq";
	int     giCount       	= 0;			//리스트 for문 break문에 사용
	int     giRecordcnt   	= 0;			//리스트의 카운터에 사용
	int     giPageSize    	= 10;  			// 한페이지에 나타내고자 하는 List수
	int     giBlockSize   	= 10;   		// Block의 수
	int     giCurPage     	= 1;   			// 현재 Page
	int     giCurBlock    	= 0;   			// 현재 Block
	int     giStartPos    	= 0;   			// 시작 List 위치
	int     giTotPage     	= 0;   			// 총 Page수
	int     giTotBlock    	= 0;   			// 총 Block수
	//  넘겨온 값 받기(List페이지 관련)...
	if ( giSelectPage  >  0 ) { 			// 선택된 Page값이 있을경우....     
		giCurPage  = giSelectPage;   	// 현재Page = 선택된Page 
		giCurBlock = giSelectBlock;  	// 블락page = 선택된 블락 page
	}
	//쿼리를 돌려서 가지고 오는 값
	List list = dao.getList(searchBoard,searchGubn,searchValue, giSelectPage, giPageSize);
	if (list.size() > 0 ) {
		//전체 게시물 수
		giRecordcnt = dao.getCount(searchBoard,searchGubn,searchValue); 			// 총 list 수
	}
	if (giRecordcnt > 0) {  // 조건에 맞는 값이 있으면....
		giTotPage  = giRecordcnt / giPageSize;
		if (giRecordcnt % giPageSize != 0) {
			giTotPage = giTotPage + 1;			// 총 Page수를 구한다...
		}
		giTotBlock = giTotPage / giBlockSize;
		if (giTotPage % giBlockSize != 0) {
			giTotBlock = giTotBlock + 1;		// 총 Block수를 구한다...
		}
	}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="ko">
<head>
<%@ include file="/inc/meta.jsp" %>
<script type="text/javascript">
<!--
$(document).ready(function(){
	$('#goWrite').click(function() {
		window.location.href="qna_write.jsp";
	});
	$('#seach').click(function() {
		document.getElementById("frm").sumit();
	});
});
var goView = function(data_id){
	document.getElementById("data_id").value = data_id;
	document.getElementById("frmView").submit();
};
//-->
</script>
</head>
<body>
<!-- header -->
<%@ include file="/inc/header.jsp" %>
<!-- header// -->
<!-- container -->
    <div id="container">
        <h2><img src="/img/sub0403_h2.gif" alt="자주하는질문" /></h2>
        <div class="sub-con">
        <ul class="tab04">
        <li class="one"><a href="/support/contact_list.jsp">Wedding Story for you</a></li>
        <li class="two"><a href="/support/qna_list.jsp" >Key Factors</a></li>
        <li class="three"><a href="/support/faq_list.jsp" class="hover">Key Factors</a></li>
        </ul>
        <h3><img src="/img/tit0403.gif" alt="FAQ l 회원님들께서 웨딩스토리에 자주 하는 질문을 모았습니다.  원하시는 답변이 없으시면 Q&A 게시판을 이용해 주시기 바랍니다." /></h3>
           <div class="boardTop">
            <form action="faq_list.jsp" name="frm" id="frm" method="post">
            	<select name="searchGubn">
					<option value="all" <%if(searchGubn.equals("all")){out.print(" selected='selected'");} %>>전체</option>
					<option value="title" <%if(searchGubn.equals("title")){out.print(" selected='selected'");} %>>제목</option>
					<option value="content" <%if(searchGubn.equals("content")){out.print(" selected='selected'");} %>>내용</option>		
				</select>
                <input type="text" name="searchValue" value="<%=searchValue %>" class="searchTxt" />
				<input type="image" alt="Go" src="/img/btn_search.gif" id="seach" class="bor-n" />
			</form>
            </div>
            <div class="list01">
				<table summary="번호,메뉴,제목 등록일,조회를 제공한 표" >
					<caption>뉴스</caption>
					<colgroup>
					<col width="10%" />
					<col width="50%" />
					<col width="10%" />
					<col width="10%" />
					<col width="20%" />
					</colgroup>
					<thead>
						<tr>
							<th scope="col" abbr="번호"><img src="/img/th_img01.gif" alt="번호" /></th>
							<th scope="col" abbr="제목"><img src="/img/th_img02.gif" alt="제목" /></th>
							<th scope="col" abbr="작성자"><img src="/img/th_img03.gif" alt="작성자" /></th>
							<th scope="col" abbr="작성일"><img src="/img/th_img04.gif" alt="작성일" /></th>
							<th scope="col" abbr="조회"><img src="/img/th_img05.gif" alt="조회" /></th>
						</tr>
					</thead>
					<tbody>
						<%
						if(list != null && list.size() > 0){
							giCount  = 1;
							giRecordcnt = giRecordcnt - ( giCurPage -1 ) * giPageSize;	
							giStartPos = ((giCurPage - 1) * giPageSize) + 1;
							for(int i = 0; i<list.size(); i++){
								boardModel model = (boardModel)list.get(i);
					%>
						<tr>
							<td><%=giRecordcnt %></td>
							<td class="td_left"><a href="javascript:goView('<%=model.getData_id() %>')"><%=model.getTitle() %></a></td>
							<td><%=model.getReg_id() %></td>
							<td><%=model.getReg_date() %></td>
							<td><%=model.getHit_count() %></td>
						</tr>
					<%
								giCount = giCount + 1;
								giRecordcnt = giRecordcnt - 1;
							}
						}else{
					%>
					<tr><td colspan="5">등록된 내용이 없습니다.</td></tr>
					<%
						}
					%>
					</tbody>
				</table>
                </div>
                
				<div class="paging">
					<%@ include file="/inc/page.jsp" %>
                    <div class="btn-wrt">
                    </div>
				</div>
			</div>

        <div class="advice"><img src="/img/img01.gif" alt="문의및상담 1666-0135" /></div>
        </div>



<!-- footer -->
<%@ include file="/inc/footer.jsp" %>
<!-- fooer// -->
</div>
<!-- container// -->
</div>
</div>
</div>
<form action="faq_view.jsp" method="post" name="frmView" id="frmView">
<input type="hidden" name="searchGubn" value="<%=searchGubn %>"/>
<input type="hidden" name="searchValue" value="<%=searchValue %>"/>
<input type="hidden" name="txtSelectPage" value="<%=giSelectPage %>"/>
<input type="hidden" name="txtSelectBlock" value="<%=giSelectBlock %>"/>
<input type="hidden" name="searchBoard" value="<%=searchBoard %>"/>
<input type="hidden" name="data_id" id="data_id" value=""/>
</form>
</body>
</html>